<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>忘忧网后台</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="Xadmin/css/xadmin.css">
    <link rel="stylesheet" href="Xadmin/css/login.css">
    <link rel="stylesheet" href="Xadmin/css/font.css">
    <script type="text/javascript" src="Xadmin/js/xadmin.js"></script>
    <script src="./layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="layui/layui.js" charset="utf-8"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="login-bg" style="background-image: url('image/zhuce1.png') ">

<div class="login">
    <div class="message">忘忧网后台登录</div>
    <form method="post" style="margin-top: 2rem">
        <input placeholder="请输入用户名" type="text" class="layui-input" id="UserName">
        <hr class="hr15">
        <div>
            <input style="width: 100%;" placeholder="请输入密码" type="password" class="layui-input" id="PassWord">
        </div>
        <hr class="hr15">
        <input value="登录" style="width: 100%" type="button" onclick="login()">
        <hr class="hr20">
        <input value="邮箱登录" style="width: 100%" type="button" onclick="loginEmail()">
        <hr class="hr20">
    </form>
    <p>如遇登录失败，请等待60S后重试，[忘忧网]</p>
</div>
</body>
<script>
    var layer
    layui.use('layer',function () { //导入组件
        layer=layui.layer
    })
    function login(){
        if($("#UserName").val()!=="" && $("#PassWord").val()!==""){
            $.ajax({
                url:"http://127.0.0.1:8082/User/doLogin",
                type:"get",
                data:{
                    UName:$("#UserName").val(),
                    Pwd:$("#PassWord").val()
                },
                success:function (res) {
                    var obj = JSON.parse(res) //转成JSON对象
                    if(obj.code==0){
                        window.location.href="Index2.html"
                    }else{
                        layer.alert(obj.msg)
                    }
                    console.log(obj)
                }
            })
        }else{
            layer.alert("请输入用户名或密码")
        }

    }
    function loginEmail(){
        window.location.href="Login.html"
    }
</script>
</html>